import {
	getGoodDay,
	getGoodYue,
	getGoodBan,
	getGoodNian,
	getGoodNow,
	getHotGold,
	getGoldNewProduct,
	getGoldProductNowData,
	getGoldProductLastWeekGoldDataList,
	getGoldProductLastMonthGoldDataList,
	getGoldProductLastHalfYearGoldDataList,
	getGoldProductLastYearGoldDataList
} from '../../http/huangjin/huangjinhttp.js'


export default ({
	namespaced: true,
	state: {
		getGoodAll: {
			highPrice: [],
			days: []
		},
		goodNow: {},
		hotGolds: [],
		newGolds: [],
		GoldProductNowData: {},
		GoldProductLastWeekGoldDataListdays: [],
		GoldProductLastWeekGoldDataListgoldPrice: [],
	},
	mutations: {
		getGoodAlls(state, a) {
			//console.log(a,'aaaaaaa')
			state.getGoodAll = a
		},
		getGoodNows(state, a) {
			state.goodNow = a
		},
		hotGolds(state, a) {
console.log(a,'热门');
			state.hotGolds = a
		},
		newGolds(state, a) {
			console.log(a,'新');
			state.newGolds = a
		},
		GoldProductNowData(state, a) {
			state.GoldProductNowData = a
		},
		GoldProductLastWeekGoldDataListdays(state, a) {
			state.GoldProductLastWeekGoldDataListdays = a
		},
		GoldProductLastWeekGoldDataListgoldPrice(state, a) {
			state.GoldProductLastWeekGoldDataListgoldPrice = a
		}
	},
	actions: {
		//获取一周的黄金趋势图
		async getGoodDays(cosntext, a) {


			const data = await getGoodDay(a)


			cosntext.commit('getGoodAlls', data.data)
		},
		//黄金一月趋势
		async getGoodYues(cosntext, a) {
			const data = await getGoodYue(a)

			cosntext.commit('getGoodAlls', data.data)
		},
		//黄金半年的趋势
		async getGoodBans(cosntext, a) {
			const data = await getGoodBan(a)

			cosntext.commit('getGoodAlls', data.data)
		},
		//黄金一年的趋势
		async getGoodNians(cosntext, a) {
			const data = await getGoodNian(a)

			cosntext.commit('getGoodAlls', data.data)
		},
		//获取当前黄金实时数据
		async getGoodNows(cosntext, a) {
			const data = await getGoodNow(a)

			cosntext.commit('getGoodNows', data.data)

		},
		//获取获取热门推荐
		async getHotGolds(cosntext, a) {
			const data = await getHotGold()

			cosntext.commit('hotGolds', data.data)
		},
		//获取新品黄金数据
		async getGoldNewProducts(cosntext, a) {
			const data = await getGoldNewProduct()
			console.log(data,'ddd');
			cosntext.commit('newGolds', data.data)
		},
		//根据id查询黄金
		async getGoldProductNowDatas(contex, a) {

			const data = await getGoldProductNowData(a)

			contex.commit('GoldProductNowData', data.data[0])
		},
		//根据id查询黄金趋势图
		async getGoldProductLastWeekGoldDataLists(context, a) {
			const data = await getGoldProductLastWeekGoldDataList(a)
			context.commit('GoldProductLastWeekGoldDataListdays', data.data.days)
			context.commit('GoldProductLastWeekGoldDataListgoldPrice', data.data.goldPrice)

		


		},
		//一个月
		async getGoldProductLastMonthGoldDataLists(context, a) {
			const data = await getGoldProductLastMonthGoldDataList(a)
			context.commit('GoldProductLastWeekGoldDataListdays', data.data.days)
			context.commit('GoldProductLastWeekGoldDataListgoldPrice', data.data.goldPrice)

			

		},
		//半年
		async getGoldProductLastHalfYearGoldDataLists(context, a) {
			const data = await getGoldProductLastHalfYearGoldDataList(a)
			context.commit('GoldProductLastWeekGoldDataListdays', data.data.days)
			context.commit('GoldProductLastWeekGoldDataListgoldPrice', data.data.goldPrice)
		

		},
		//一年
		async getGoldProductLastYearGoldDataList(context,a){
			const data = await getGoldProductLastYearGoldDataList(a)
			context.commit('GoldProductLastWeekGoldDataListdays', data.data.days)
			context.commit('GoldProductLastWeekGoldDataListgoldPrice', data.data.goldPrice)
		}
	},


})
